#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
    int b=0,b2=0,b3=0;
    cin >> b >> b2 >> b3;
    while(true){
        char a = ' ';
        cin >> a;
        if(a=='s'){
            
            cout << b << ' ' << b2 << ' ' <<  b3 << ' ' << b*100 + b2*10 + b3 << endl;
            cout << endl;
        }
        int n,n2,n3;
        cin >> n >> n2 >> n3;
        b += n;
        b2 += n2;
        b3 += n3;
        if(b3 >= 10){
            b2 += b3 / 10;
            b3 %= 10; 
        }
        if(b2 >= 10){
            b += b2 / 10;
            b2 %= 10; 
        }
        

    }
    cout << b << ' ' << b2 << ' ' <<  b3 << ' ' << b*100 + b2*10 + b3;
    return 0;
}